Method and Apparatus for Implementing Layers on a Convolutional Neural Network Accelerator

ABSTRACT

A method for implementing a convolutional neural network (CNN) accelerator on a target includes utilizing one or more processing elements to implement a standard convolution layer. A configuration of the CNN accelerator is modified to change a data flow between components on the CNN accelerator. The one or more processing elements is utilized to implement a fully connected layer in response to the change in the data flow.

RELATED APPLICATION

This application is a continuation-in-part of, and claims the benefitunder Title 35, United States Code, Section 120 of co-pending U.S.application Ser. No. 14/879,928 filed on Oct. 9, 2015 and entitled“Method and Apparatus for Designing and Implementing a ConvolutionNeural Net Accelerator”. This application also claims benefit andpriority to Provisional U.S. Patent Application No. 62/238,598 filedOct. 7, 2015 entitled “Method and Apparatus for Designing andImplementing Standard and Fully-Connected Convolution Layers on aConvolutional Neural Network Accelerator”, the full and complete subjectmatter of which is hereby expressly incorporated by reference in itsentirety.

FIELD

Embodiments of the present invention relate to tools for designingsystems on target devices. More specifically, embodiments of the presentinvention relate to a method and apparatus for implementing layers on aconvolutional neural network accelerator.

BACKGROUND

As images and videos have become more ubiquitous on the Internet, theneed arises for algorithms with the capability to efficiently analyzetheir semantic content for various applications, including search andsummarization. Convolutional neural networks (CNNs) have been shown tobe effective tools for performing image recognition, detection, andretrieval. CNNs may be scaled up and configured to support large labeleddatasets that are required for the learning process. Under theseconditions, CNNs have been found to be successful in learning complexand robust image features.

A CNN is a type of feed-forward artificial neural network whereindividual neurons are tiled in a manner such that they respond tooverlapping regions in a visual field. CNNs are inspired by the behaviorof optic nerves in living creatures. CNNs process data with multiplelayers of neuron connections to achieve high accuracy in imagerecognition. Developments in multi-layer CNNs have led to improvement inthe accuracy of complex recognition tasks such as large-category imageclassification, automatic speech recognition, as well as other dataclassification/recognition tasks.

The limitations in computing power of a single processor have led to theexploration of other computing configurations to meet the demands forsupporting CNNs. Among the areas of exploration, CNN accelerators whichutilize hardware specialization in the form of general purpose computingon graphics processing units (GPGPUs), multi-core processors, fieldprogrammable gate arrays (FPGAs), and application specific integratedcircuits (ASICs) have been researched.

SUMMARY

According to an embodiment of the present invention, a methodology fordesigning and implementing a convolutional neural network (CNN)accelerator is disclosed. The methodology utilizes an electronic designautomation (EDA) tool that generates a design for the CNN accelerator inresponse to features of a CNN accelerator which may includecharacteristics and parameters of the CNN accelerator specified by auser, and available resources on a target selected by the user. Thetarget may include one or more target devices of one or more types. TheEDA tool assigns resources on the target to implement the CNNaccelerator to achieve high performance. For example, resources on thetarget are assigned to implement appropriately sized buffers to handlethe types and sizes of images to be processed by the CNN accelerator.Resources on the target are also assigned to implement the appropriatetypes and number of computation units, such as processing elements, tosupport the type of filters and layers applied by the CNN accelerator.The EDA tool also generates a sequencer unit that is programmed tocoordinate the transmission of data to appropriate computation units inorder to time multiplex computations on the computation units.

According to an embodiment of the present invention, a range ofcharacteristics may be specified by the user to allow the CNNaccelerator to execute a plurality of CNN algorithms. In thisembodiment, one or more configurable status registers (CSRs) areimplemented to allow a user to configure the target to support specifiedcharacteristics required for executing one of the plurality of CNNalgorithms at runtime, after the CNN accelerator is programmed on thetarget. When implemented on an field programmable gate array (FPGA), theCSRs effectively allow runtime configuration of the CNN accelerator.This facilitates an FPGA overlay targeted at CNN applications.

According to an embodiment of the present invention, a method forimplementing a CNN accelerator on a target includes identifying a CNNalgorithm to execute on the CNN accelerator. A variation of the CNNaccelerator is identified that supports execution of the CNN algorithm.The variation of the CNN may include a specific number or type ofconvolution layers, pooling layers, filter size, and/or filtercoefficient. CSRs on the target device may be set to support the desiredvariation. When a different CNN algorithm is desired to be executed onthe target device, a different variation of the CNN accelerator may beidentified that supports the different CNN algorithm. The CSRs on thetarget device may be set to support the different variation of the CNNaccelerator.

According to an embodiment of the present invention, a method forimplementing a CNN accelerator on a target includes utilizing one ormore processing elements to implement a standard convolution layer. Aconfiguration of the CNN accelerator is modified to change a data flowbetween components on the CNN accelerator. The one or more processingelements are utilized to implement a fully connected layer in responseto the change in the data flow.

According to an embodiment of the present invention, a CNN acceleratorimplemented on a target includes a sequencer unit that coordinates afirst data flow between components on the target during a firstconfiguration and that coordinates a second data flow between componentson the target during a second configuration. The CNN accelerator alsoincludes a plurality of processing elements that implement a standardconvolutional layer during the first configuration, and that implement afully connected layer during the second configuration.

BRIEF DESCRIPTION OF THE DRAWINGS

The features and advantages of embodiments of the present invention areillustrated by way of example and are not intended to limit the scope ofthe embodiments of the present invention to the particular embodimentsshown.

FIG. 1 is a flow chart illustrating a method for designing andimplementing a convolutional neural network (CNN) accelerator accordingto an exemplary embodiment of the present invention.

FIG. 2 is a flow chart illustrating a method for identifying features ofa CNN accelerator according to an exemplary embodiment of the presentinvention.

FIG. 3 illustrates an example of a standard convolutional layerimplemented by an exemplary embodiment of the present invention.

FIG. 4 illustrates an example of a fully-connected layer implemented byan exemplary embodiment of the present invention.

FIG. 5 is a flow chart illustrating a method for generating a design fora CNN accelerator according to an embodiment of the present invention.

FIG. 6 is a flow chart illustrating a method for compiling a design fora CNN according to an exemplary embodiment of the present invention.

FIG. 7 is a flow chart illustrating a method for configuring a CNNaccelerator on a target according to an exemplary embodiment of thepresent invention.

FIG. 8 illustrates an exemplary CNN according to an exemplary embodimentof the present invention.

FIG. 9 is a block diagram of a CNN accelerator according to an exemplaryembodiment of the present invention.

FIG. 10 is a block diagram illustrating a processing element accordingto an exemplary embodiment of the present invention.

FIG. 11 is a flow chart illustrating a method for utilizing one or moreprocessing elements to implement a standard convolutional layer and afully connected layer according to an exemplary embodiment of thepresent invention.

FIG. 12 is a flow chart illustrating a method for managing data inputand output on a CNN accelerator to utilize one or more processingelements to implement a standard convolutional layer according to anexemplary embodiment of the present invention.

FIG. 13 is a flow chart illustrating a method for managing data inputand output on a CNN accelerator to utilize one or more processingelements to implement a fully connected layer according to an exemplaryembodiment of the present invention.

FIG. 14 illustrates a block diagram of a computer system implementing anelectronic design automation tool and a CNN accelerator configurationtool according to an exemplary embodiment of the present invention.

FIG. 15 is a block diagram of an electronic design automation toolaccording to an exemplary embodiment of the present invention.

FIG. 16 illustrates a block diagram of a CNN accelerator configurationtool according to an exemplary embodiment of the present invention.

FIG. 17 illustrates an exemplary target device according to anembodiment of the present invention.

DETAILED DESCRIPTION

In the following description, for purposes of explanation, specificnomenclature is set forth to provide a thorough understanding ofembodiments of the present invention. It will be apparent to one skilledin the art that specific details in the description may not be requiredto practice the embodiments of the present invention. In otherinstances, well-known circuits, devices, procedures, and programs areshown in block diagram form to avoid obscuring embodiments of thepresent invention unnecessarily.

FIG. 1 is a flow chart illustrating a method for designing andimplementing a convolutional neural network (CNN) accelerator accordingto an exemplary embodiment of the present invention. The proceduresdescribed in FIG. 1 may be performed by an electronic design automation(EDA) tool and an CNN accelerator configuration tool on a computersystem. The procedures described may also be performed in combinationwith other tools or systems. At 101, features of a design for the CNNaccelerator are identified. According to an embodiment of the presentinvention, identifying features of the design include identifyingcharacteristics and parameters for the CNN accelerator, and resourcesavailable on a target implementing the CNN accelerator. It should beappreciated that when the CNN accelerator is desired to support morethan one CNN algorithm, a plurality or range of characteristics andparameters may be identified. According to an embodiment of the presentinvention, the features of the design for the CNN accelerator may beprovided in a high level design language such as OpenCL or other designlanguage.

At 102, a design for the CNN accelerator is generated. According to anembodiment of the present invention, an architecture description of thedesign for the CNN accelerator is generated in response to the featuresof the CNN accelerator. The design for the CNN accelerator may beoptimized for the target implementing the CNN accelerator. According toan embodiment of the present invention, the design for the CNNaccelerator may be generated in a high level design language or ahardware description language.

At 103, the design for the CNN accelerator is compiled for the target.According to an embodiment of the present invention, compilationinvolves performing synthesis, placement, routing, and timing analysisprocedures on a hardware description language of the design. Thecompiled design for the CNN accelerator supports a range of CNNvariants.

At 104, the CNN accelerator is configured on the target. According to anembodiment of the present invention, the target is programmed using thecompiled design of the CNN accelerator. The target is further configuredto implement a variation of the CNN accelerator to support execution ofa desired CNN algorithm. During runtime, further configurations may beapplied to implement other variations of the CNN accelerator to supportexecution of other CNN algorithms.

FIG. 2 is a flow chart illustrating a method for identifying designfeatures for a CNN accelerator according to an embodiment of the presentinvention. The procedures described in FIG. 2 may be used to implementprocedure 101 in FIG. 1 and may be performed by an EDA tool executed ona computer system. At 201, characteristics of the CNN accelerator areidentified. According to an embodiment of the present invention,identifying the characteristics for the CNN accelerator may includeidentifying characteristics of one or more CNN algorithms that the CNNaccelerator is desired to support. The characteristics of a CNNalgorithm may include a number and sequence of stages of layers, such asconvolution (standard convolutional) and noise filtering layers. Thenoise filtering layers may include, for example, pooling, normalization,and rectified linear (ReLU) layers. The characteristics of the CNNalgorithm may also include sizes and coefficients of filters, and sizes,strides, and padding of images to be processed. According to anembodiment of the present invention, a stride of an image corresponds toa number of pixels that may be skipped in an input when performingconvolution and may be used to adjust a number of output results.Padding of an image relates to values added to a perimeter of an imageand may be used to match input and output images. It should beappreciated that other characteristics may also be identified.

FIG. 3 illustrates an example of a standard convolution layerimplemented by an exemplary embodiment of the present invention. Thestandard convolution layer may be one of the layers identified at 201,described with reference to FIG. 2. The standard convolution layerreceives input features from an input feature map 310. The standardconvolution layer also receives a set of coefficients 321-323 generatedthrough a training of the convolution layer. The coefficients 321-323apply weights which formulate a filter for the convolution layer. Thestandard convolution layer performs a 3-dimensional dot product betweena region 330 defined within the input features 310 and the coefficients321-323. The result of each convolution operation is an output at thesame (x, y) horizontal and vertical coordinates within the output planes341-343. Applying the same set of coefficients on different featureregions produces different (x,y) outputs on each output plane 341-343.Therefore, in order to produce the entire (x,y) output planes, thestandard convolution layer receives a stream of different input featureswhile applying the same set of coefficients 321-323. According to anembodiment of the present invention, a single (x,y) output generated bya single standard convolution over a kxkxD input region 330 may berepresented with the following relationship.

${output} = {\sum\limits_{c = 0}^{D}\; {\sum\limits_{r = 0}^{k}\; {\sum\limits_{s = 0}^{k}\; {{{{{feature}\lbrack c\rbrack}\lbrack r\rbrack}\lbrack s\rbrack} \star {{{{coef}\lbrack c\rbrack}\lbrack r\rbrack}\lbrack s\rbrack}}}}}$

In the relationship above, D represents an input depth, and k representsa height and width of a region in an input feature map. Different k×k×Dcoefficient data is used to compute every (x,y) output plane of eachconvolution layer. Hence, for instance, if a convolution layer has Houtput planes, a total of H×k×k×D coefficient data is needed for thisconvolution layer. However, the same H×k×k×D coefficient data is used inthe same convolution layer when processing different images.

FIG. 4 illustrates an example of a fully-connected layer implemented byan exemplary embodiment of the present invention. The fully-connectedlayer receives input features 410 which represent all the feature datafrom an input feature map. The fully-connected layer also receives a setof coefficients 421-423 generated through a training of thefully-connected layer. The coefficients 421-423 apply weights whichformulate a filter for the fully-connected layer. The fully-connectedlayer takes a 1-dimensional dot product between the input features 410and the set of coefficients 421-423. The results of the operation areoutputs 431-433 which form the output feature map. If the output size isZ, and the input size is N, then the total size of the coefficients isZ×N, i.e. the total size of the coefficient data is larger than the sizeof the features. Hence, in order to compute the entire output featuremap, the fully-connected layer receives a stream of differentcoefficients while applying a same input features 410 of the same image.According to an embodiment of the present invention, a single output zmay be represented with the following relationship.

${{output}\lbrack z\rbrack} = {\sum\limits_{i = 0}^{N}\mspace{11mu} {{{feature}\lbrack i\rbrack} \star {{{coef}\lbrack z\rbrack}\lbrack i\rbrack}}}$

In the relationship above, N represents the size of the input featuremap and z represents the index of the output feature that is computed,where the total size of output feature map is Z. Different coefficientdata is used to compute the output features of different fully connectedlayers. However, the same Z×N coefficient data is used in the same fullyconnected layer when processing different images.

Referring back to FIG. 2, at 202, parameters of the CNN accelerator areidentified. According to an embodiment of the present invention,identifying parameters for the CNN accelerator may include identifyingparameters for the one or more CNN algorithms that the CNN acceleratoris desired to support. The parameters of a CNN algorithm may include anumber of processing elements to instantiate for each layer identified,and a number of multiplications to execute for each cycle of a kernel.It should be appreciated that other parameters may also be identified.

At 203, resources available on a target to implement the CNN acceleratorare identified. According to an embodiment of the present invention thetarget may include one or more target devices of one or more targetdevice types. The resources identified may include a number and type ofmemory blocks, digital signal processors (DSPs), and other componentsand processing units on a target device. According to an embodiment ofthe present invention, the features of the CNN may be identified frominput provided by the user or from other sources.

FIG. 5 is a flow chart illustrating a method for generating a design fora CNN accelerator according to an embodiment of the present invention.The procedures described in FIG. 5 may be used to implement procedure102 in FIG. 1 and may be performed by an EDA tool executed on a computersystem. At 501, buffers on the CNN accelerator are assigned anappropriate size to support a size of images to be processed by the CNNaccelerator. According to an embodiment of the present invention, thedesign for the CNN accelerator architecture is structured such thatthere is one read port and one write port for each buffer. This ensuresan efficient implementation that does not require arbitration to accessdata in the buffer. According to one embodiment, double buffering issupported to allow writing of new intermediate results from aconvolution stage while reading results from a previous stage in adifferent location in the buffer.

At 502, computation units are generated to support the CNN algorithms tobe performed by the CNN accelerator. According to an embodiment of thepresent invention, the computation units include kernels that performconvolution and noise filtering. The computation units may be generatedto maximize performance utilizing resources available on a targetimplementing the CNN accelerator. The resources available on the targetthat may be utilized may include DSP blocks, memory blocks, shiftregisters, and adders. In one embodiment, dot product computationsperformed by kernels are organized to leverage vector modes supported byreconfigurable DSP blocks on the target. In another embodiment, poollayers utilize shift register resources available on the target.

At 503, a sequencer unit is generated. The sequencer unit coordinatestransmission of data to appropriate processing elements on the CNNaccelerator at appropriate times in order to time multiplex computationson the processing elements. According to an embodiment of the presentinvention, the sequencer unit is programmed to perform the coordinationrequired to support the algorithms performed by the CNN accelerator. Thesequencer unit may be generated using logic array blocks, registers,and/or a hard or soft processing unit available on a target device.

At 504, a description of the design is generated. According to anembodiment of the present invention, the description of the design maybe in a hardware description language (HDL) format or other format.

FIG. 6 is a flow chart illustrating a method for compiling a design fora CNN accelerator on a target according to an exemplary embodiment ofthe present invention. The target may be one or more field programmablegate arrays (FPGAs), application specific integrated circuits (ASICs),structured ASICs, or other programmable device. The procedures describedin FIG. 6 are referred to as a compilation flow. The procedures may beused to implement procedure 103 in FIG. 1 and may be performed by an EDAtool executed on a computer system.

At 601, a design for the CNN accelerator is synthesized. Synthesisincludes generating a logic design of the system to be implemented bythe target. According to an embodiment of the present invention,synthesis generates an optimized logical representation of the systemfrom an HDL design definition. The optimized logical representation ofthe system may include a representation that has a minimized number offunctional blocks, such as logic gates, logic elements, and registers,required for the system. Synthesis also includes mapping the optimizedlogical representation. Mapping includes determining how to implementlogic gates and logic elements in the optimized logic representationwith the types or categories of resources available on the target. Theresources available on the target may be referred to as “cells” or“components” and may include logic-array blocks, registers, memories,DSP blocks, input-output elements, and other components. According to anembodiment of the present invention, a netlist is generated frommapping. This netlist may be an optimized technology-mapped netlistgenerated from the HDL.

At 602, the system is placed. According to an embodiment of the presentinvention, placement involves placing the technology-mapped logicalsystem design on the target. Placement includes fitting the system onthe target by determining which specific resources on the target are tobe assigned to and implemented by the technology-mapped netlistdetermined during synthesis. Placement may include clustering whichinvolves grouping logic elements together to form the logic clusterspresent on the target.

At 603, the placed design is routed. During routing, routing resourceson the target are allocated to provide interconnections between logicgates, logic elements, and other components on the target device.Routability optimization may also be performed on the placed logicdesign. According to an embodiment of the present invention, the goal ofroutability optimization is to reduce the amount of wiring used toconnect components in the placed logic design. Routability optimizationmay include performing fanout splitting, logic duplication, logicalrewiring, or other procedures. It should be appreciated that one or moreof the procedures may be performed on the placed logic design.

At 604, timing analysis is performed on the design of the system.According to an embodiment of the present invention, the timing analysisdetermines whether timing constraints of the system are satisfied.According to an embodiment of the present invention, timing analysisestablishes a length for each path in the system as well as the slackfor each path in the system. Slack may be defined to be the amount ofdelay that can be added to a path before it becomes critical or requiredtime for signal arrival minus actual time of signal arrival.

At 605, assembly is performed. The assembly procedure involves creatinga configuration file that includes information determined by theprocedures described at 601-604. The configuration file may be a bitstream that may be used to program the target to implement the CNNaccelerator. Programming the target physically transforms programmableresources on the target into the design of the CNN accelerator.

FIG. 7 is a flow chart illustrating a method for configuring a CNNaccelerator on a target according to an exemplary embodiment of thepresent invention. The procedures illustrated in FIG. 7 may be used toimplement procedure 104 in FIG. 1 and be performed by a CNN acceleratorconfiguration tool on a computer system. At 701, a target is programmedto implement the CNN accelerator. According to an embodiment of thepresent invention, programming the target involves programming one ormore target devices with a configuration file that physically transformsthe one or more target devices into the design of the CNN accelerator.

At 702, a CNN algorithm to be executed by the CNN accelerator isidentified. According to an embodiment of the present invention, the CNNalgorithm to be executed may be identified from user input or fromanother source.

At 703, an appropriate variation of the CNN accelerator that supportsthe CNN algorithm to be executed is identified. According to anembodiment of the present invention, the appropriate variation of theCNN accelerator may be identified from user input or from anothersource.

At 704, one or more configurable status registers are set to support thevariation of the CNN accelerator. According to an embodiment of thepresent invention, setting a configurable status register may add orsubtract a convolution layer on the CNN accelerator, add or subtract oneor more noise filtering layers, or change a size of a filter.

At 705, a determination is made as to whether a new CNN algorithm is tobe executed by the CNN accelerator. According to an embodiment of thepresent invention, the determination may be made in response to userinput. If a determination is made that a new CNN algorithm is to beexecuted by the CNN accelerator, control proceeds to 702. If adetermination is made that a new CNN algorithm is not to be executed bythe CNN accelerator, control returns to 705.

FIGS. 1-2, and 5-7 are flow charts that illustrate embodiments of thepresent invention. The procedures described in these figures may beperformed by an EDA tool and a CNN accelerator configuration toolimplemented by one or more computer systems. Some of the techniquesillustrated may be performed sequentially, in parallel or in an orderother than that which is described and that the procedures described maybe repeated. It is appreciated that not all of the techniques describedare required to be performed, that additional techniques may be added,and that some of the illustrated techniques may be substituted withother techniques.

FIG. 8 illustrates a conceptual view of an exemplary CNN algorithm 800that may be implemented according to an exemplary embodiment of thepresent invention. The CNN 800 includes a plurality of layers where eachlayer transforms one volume of activations to another volume through adifferentiable function. The CNN 800 includes five convolution layers811-815. The convolution layer computes an output of neurons that areconnected to local regions in an input. The convolution layer computes adot product between its coefficients (weights) and the region it isconnected to in an input volume. According to an embodiment of thepresent invention, each of the convolution layers 811-815 may performthe operations described with reference to the standard convolutionlayer described in FIG. 3.

The CNN 800 includes three max-pooling layers 821-823. A pooling layerperforms a down-sampling operation along spatial dimensions. Poolinglayers reduce variance by computing a maximum or average value of aparticular feature over a region of an image. This ensures that a sameresult will be obtained even when image features have small translation.This operation may be used for object classification and detection.

The CNN 800 includes three fully-connected layers 831-833. Thefully-connected layers 831-833 perform high-level reasoning. Thefully-connected 831-833 layers take all neurons from a previous layerand connect them to every neuron in its layer. According to anembodiment of the present invention, each of the fully-connected layers831-833 may perform the operations described with reference to thefully-connected layer described in FIG. 4.

It should be appreciated that a CNN may include other layers. Forexample, one or more ReLU layers may be used to apply an element-wiseactivation function such as max (0,x). The ReLU layer increasesnon-linear properties of a decision function and of an overall CNNwithout affecting the receptive fields of a convolution layer.

FIG. 9 is a block diagram of an exemplary CNN accelerator 900 that maybe used to implement a CNN according to an embodiment of the presentinvention. The CNN accelerator 900 allows for efficient computation offorward propagation of convolution and other layers. The CNN accelerator900 accepts an input image (feature map) and may apply multipleconvolution and other layers in succession.

Input image pixels are transmitted into the processing element (PE)arrays 901-904 which may perform independent dot-product operations in aconvolution procedure. PE array 901 represents a first PE array and PEarray 904 represents an nth PE array, where n can be scaled to anynumber. According to an embodiment of the present invention, each PEarray includes hardware components that support layers such as aconvolution layer, ReLU layer, normalization layer, and pooling layer.

A sequencer unit 920 orchestrates the sequencing, addressing, anddelivery of data to each of the PE arrays 901-904, kernels in each ofthe PE arrays 901-904, and components in each of the kernels. Thesequencer unit 920 coordinates the transmission of data to appropriatePE arrays 901-904 in order to time multiplex computations on the PEarrays 901-904. The accumulated results from the PE arrays 901-904 maybe transmitted to one of the buffers 951-954 which transmits thecomputed output layer back to kernels and components in the PE arrays901-904 for a next round of layer computation. The buffers 951-954reside on a target device implementing the CNN accelerator 900 and maybe referred to as on-chip buffers.

The CNN accelerator 900 includes configurable status registers (CSRs)960. The CSRs 960 are programmable by a user during runtime to modifyvarious aspects of the CNN accelerator 900. For example, the CSRs 960may be set to add or subtract a number of convolution layers used by theCNN accelerator 900, add or subtract one or more pooling, ReLU, or otherlayers used by the CNN accelerator 900, and/or change a size of a filtersupported by the CNN accelerator 900. The CSRs 960 may be coupled toeach of the components of the PE arrays 901-904.

According to an embodiment of the present invention, each of the PEarrays 901-904 includes a first kernel 911-914, that supports aconvolution layer, a second kernel 921-924, that supports a ReLU layer,a third kernel 931-934, that supports a normalization layer, and afourth kernel 941-944, that supports a pooling layer. The output of thefourth kernel, 941-944, is transmitted to a buffer 951-954 from where itmay be fed back into the first kernel 911-914 for the next convolutionstage. According to an embodiment of the present invention, a singlekernel may support the normalization layer. In this embodiment, thesingle normalization kernel would be connected to kernels 921-924 thatsupport the ReLU layer. It should be appreciated that each of the PEarrays 901-904 may include kernels that implement layers other than theones illustrated in FIG. 9, such as fully-connected layers. According toan embodiment of the present invention, the first kernels 911-914 may beused to implement both convolution layers and fully-connected layers.

Although buffers 951-954 are shown to be connected to the fourth kernels941-944 in the PE arrays 901-904, it should be appreciated that buffers951-954 may be directly connected to any of the kernels in the PE arrays901-904. According to an embodiment of the present invention, the firstkernels 911-914 in the PE arrays 901-904 are directly connected to thebuffers 951-954 and may store data in the buffers 951-954 withoutrouting the data through any other kernel.

FIG. 10 is a block diagram illustrating an exemplary processing element1000 according to an exemplary embodiment of the present invention. Theprocessing element 1000 may be used to implement any one of the firstkernels 911-914 illustrated in FIG. 9 that supports a convolution layer.It should be appreciated that the processing element 1000 may also beused to support a fully-connected layer. According to an embodiment ofthe present invention, the processing element 1000 includes a cache 1010for storing recycled, repeated data. The cache 1010 may be implementedusing a memory block on a target device. The processing element 1000includes a dot product unit 1020 that computes N-float dot productsevery clock cycle. According to an embodiment of the present invention,N is configured at 202. The dot product unit 1020 receives streaming,non-repeated data and recycled, repeated data. The dot product unit 1020may be implemented using one or more DSP blocks on the target. Theprocessing element 1000 includes an accumulator unit 1030. Theaccumulator unit 1030 accumulates dot product results as partial sumsuntil an entire computation is completed. The accumulator unit 1030 maybe implemented using a logic array block.

One or more processing elements may be used together with off-chipmemory interfaces, on-chip buffers, and control logic to route data intoand out of the one or more processing elements to support computationsperformed by a variety of algorithms. These computations include matrixmultiplication, and 1D/2D/3D convolutions. One or more processingelements may also be used to implement both a standard convolution layerand a fully-connected layer at different instances of time. The numberof processing elements and their configurations may be adjusted to matchthe performance and resource requirements of the CNN algorithm.

A first input to the processing element 1000 may be used to stream innon-repeated data. A second input to the processing element 1000 is usedto stream in repeated data that is used more than once. The non-repeateddata may be stored in an on-chip buffer and streamed in directly intothe dot product unit 1020. Repeated data may be read from an externalmemory and stored in the cache 1010. The cache 1010 may be utilized totake advantage of temporal locality of the repeated data.

When implementing a standard convolution layer using one or more of theprocessing elements, feature map data is treated as non-repeated dataand stored in on-chip buffers 951-954. The output of one convolutionlayer is streamed into a next convolution layer. Each processing elementreceives the same streaming feature data that belongs to the same imageevery cycle to compute an output in the same (x,y) output coordinates indifferent output planes. Coefficient data is treated as repeated datasince the same set of coefficients is used to compute different outputfeature maps in the same (x,y) output plane. The coefficient data isread into the cache 1010 of the processing element 1000. Differentcaches store different coefficient data needed to process differentoutput planes. The coefficient data may be read into the cache 1010 froman external memory, but is not written back. Utilizing the cache 1010reduces required accesses to the external memory.

When implementing a fully-connected layer using one or more of theprocessing elements, coefficient data is treated as non-repeated dataand is stored in on-chip buffers 951-954. The coefficient data istreated as non-repeated data since different sets of coefficient dataare used to compute different output features of each image. Sets ofcoefficient data are read once from external memory, stored on on-chipbuffers, and streamed into processing elements. Alternatively,coefficient data may also be streamed directly from DDR without beingstored on on-chip buffers. Fully connected layers are computed using abatch mode; a number of images are processed simultaneously in that eachprocessing element applies the same fully connected layer for adifferent image. Since the same coefficient data is used for differentimages, each processing element receives the same coefficient data everycycle to apply to different feature data that belong to different imagesand to compute different output features of different images. Featuredata is treated as repeated data. The input features are read fromexternal memory into the cache 1010. The caches in different processingelements store features data for different images. Input feature data istreated as repeated data since the same input feature data is used tocompute different output features of the same image. The final outputfeature maps computed are stored in external memory.

FIG. 11 is a flow chart illustrating a method for utilizing one or moreprocessing elements to implement a standard convolutional layer and afully connected layer according to an exemplary embodiment of thepresent invention. The method illustrated in FIG. 11 may be performed bya sequencer unit such as the sequencer unit 920 illustrated in FIG. 9.At 1101, a layer to implement on a CNN accelerator is identified.According to an embodiment of the present invention, the layer toimplement may be identified from characteristics of the CNN acceleratorand tracking a stage in which data is being processed by the CNNaccelerator.

At 1102, it is determined whether the layer to implement is a standardconvolution layer. If the layer to be implemented is a standardconvolution layer, control proceeds to 1103. If the layer to beimplemented is not a standard convolution layer, control proceeds to1104.

At 1103, data flow is coordinated to implement a standard convolutionlayer. The data flow that is coordinated includes data input and outputto and from one or more processing elements and components residing onand off the CNN accelerator.

At 1104, data flow is coordinated to implement a fully connected layer.The data flow that is coordinated includes data input and output to andfrom one or more processing elements and components residing on and offthe CNN accelerator. It should be appreciated that the proceduresillustrated in FIG. 11 may be repeated such that control returns toprocedure 1101 after procedures 1103 or 1104 are completed.

FIG. 12 is a flow chart illustrating a method for managing data inputand output on a CNN accelerator to utilize one or more processingelements to implement a standard convolutional layer according to anexemplary embodiment of the present invention. The method described inFIG. 12 may be used to implement procedure 1103 illustrated in FIG. 11.At 1201, an input feature map is stored on an on-chip buffer.

At 1202, data from the input feature map is streamed into a processingelement from the on-chip buffer.

At 1203, coefficient data is stored in a cache of the processingelement. The input feature map streamed into the processing element andthe coefficient data stored in the cache of the processing element maybe processed by the processing element in the manner described withreference to FIG. 3 to generate an output feature map.

At 1204, it is determined whether a present standard convolution layeris a last standard layer to be implemented for processing the featuremap. If the present standard convolution layer is not the last standardconvolution layer to be implemented, control proceeds to 1205. If thepresent standard convolution layer is the last standard layer to beimplemented, control proceeds to 1206.

At 1205, the generated output feature map is stored on the on-chipbuffer. Control returns to 1202.

At 1206, the generated output feature map is stored in an externalmemory. The external memory may reside off the target implementing theCNN accelerator. Control proceeds to 1207 where the procedure isterminated.

FIG. 13 is a flow chart illustrating a method for managing data inputand output on a CNN accelerator to utilize one or more processingelements to implement a fully connected layer according to an exemplaryembodiment of the present invention. The method described in FIG. 13 maybe used to implement procedure 1104 illustrated in FIG. 11. At 1301, aninput feature map is stored in a cache of a processing element.

At 1302, coefficient data is stored on an on-chip buffer.

At 1303, the coefficient data is streamed into the processing elementfrom the on-chip buffer. The input feature map stored in the cache ofthe processing element and the coefficient data streamed from theon-chip buffer may be processed by the processing element in the mannerdescribed with reference to FIG. 4 to generate an output feature map.

At 1304, it is determined whether a present fully-connected layer is alast fully-connected layer to be implemented for processing the featuremap. If the present fully-connected layer is not the lastfully-connected layer to be implemented, control proceeds to 1305. Ifthe present fully-connected layer is the last fully-connected layer tobe implemented, control proceeds to 1306.

At 1305, the generated output feature map is stored in the cache.Control returns to 1302.

At 1306, the generated output feature map is stored in an externalmemory. The external memory may reside off the target implementing theCNN accelerator. Control proceeds to 1307 where the procedure isterminated.

FIGS. 11-13 are flow charts that illustrate embodiments of the presentinvention. The procedures described in these figures may be performed bya sequencer unit implemented by a CNN accelerator, and may be used toprogram the sequencer unit as described with reference to 503 in FIG. 5.Some of the techniques illustrated may be performed sequentially, inparallel or in an order other than that which is described and that theprocedures described may be repeated. It is appreciated that not all ofthe techniques described are required to be performed, that additionaltechniques may be added, and that some of the illustrated techniques maybe substituted with other techniques.

FIG. 14 illustrates a block diagram of a computer system 1400implementing a system designer according to an embodiment of the presentinvention. The computer system 1400 includes a processor 1410 thatprocess data signals. The processor 1410 is coupled to a bus 1401 orother switch fabric that transmits data signals between processor 1410and other components in the computer system 1400. The computer system1400 includes a memory 1420. The memory 1420 may store instructions andcode represented by data signals that may be executed by the processor1410. A data storage device 1430 is also coupled to the bus 1401

A network controller 1440 is coupled to the bus 1401. The networkcontroller 1440 may link the computer system 1400 to a network ofcomputers (not shown) and supports communication among the machines. Adisplay device controller 1450 is coupled to the bus 1401. The displaydevice controller 1450 allows coupling of a display device (not shown)to the computer system 1400 and acts as an interface between the displaydevice and the computer system 1400. An input interface 1460 is coupledto the bus 1401. The input interface 1460 allows coupling of an inputdevice (not shown) to the computer system 1400 and transmits datasignals from the input device to the computer system 1400.

An EDA tool 1421 may reside in the memory 1420 and be executed by theprocessor 1410. According to an embodiment of the present invention, theEDA tool 1421 operates to identify features of a CNN accelerator whichincludes characteristics and parameters of the CNN accelerator, andresources of a target that the CNN accelerator is to be implemented on.The EDA tool 1421 generates a design for the CNN accelerator in responseto the features of the CNN accelerator and the resources of the target.

A CNN accelerator configuration tool 1422 may reside in the memory 1420and be executed by the processor 1410. According to an embodiment of thepresent invention, the CNN accelerator configuration tool 1422identifies a CNN algorithm to execute on a CNN accelerator, identifies avariation of the CNN accelerator that supports execution of the CNNalgorithm, and sets configurable status registers on a target to supportthe variation of the CNN accelerator.

FIG. 15 illustrates an EDA tool 1500 according to an embodiment of thepresent invention. The EDA tool 1500 may be used to implement the EDAtool 1421 illustrated in FIG. 14. The EDA tool 1500 may be used fordesigning a system such as a CNN accelerator on one or more targetdevices such as an FPGA, ASIC, structured ASIC, or other circuitry. FIG.15 illustrates modules implementing an embodiment of the EDA tool 1500.According to one embodiment, the modules represent software modules anddesigning a CNN accelerator may be performed by a computer system suchas the one illustrated in FIG. 14 executing sequences of instructionsrepresented by the modules shown in FIG. 15. Execution of the sequencesof instructions causes the computer system to support system design aswill be described hereafter. In alternate embodiments, hard-wirecircuitry may be used in place of or in combination with softwareinstructions to implement embodiments of present invention. Thus,embodiments of present invention are not limited to any specificcombination of hardware circuitry and software.

The EDA tool 1500 includes an EDA tool manager 1510. The EDA toolmanager 1510 is connected to and transmits data between the othercomponents of the EDA tool 1500. The EDA tool manager 1510 provides aninterface that allows a user such as a designer to input data into theEDA tool 1500.

The EDA tool 1500 includes a CNN accelerator feature identification unit1520. According to an embodiment of the present invention, the CNNaccelerator feature identification unit 1520 identifies characteristicsof the CNN accelerator by identifying characteristics of one or more CNNalgorithms that the CNN accelerator is desired to support. Thecharacteristics of a CNN algorithm may include a number and sequence ofstages of layers, such as convolution and noise filtering layers. Thenoise filtering layers may include, for example, pooling, normalization,and ReLU layers. The characteristics of the CNN algorithm may alsoinclude sizes and coefficients of filters, and sizes and strides ofimages to be processed. The CNN feature identification unit 1520 alsoidentifies parameters of the CNN accelerator by identifying parametersfor the one or more CNN algorithms that the CNN accelerator is desiredto support. The parameters of a CNN algorithm may include a number ofkernels to instantiate for each layer identified, and a number ofmultiplications to execute for each cycle of a kernel, and otherparameters. The CNN feature identification unit 1520 also identifiesresources available on a target to implement the CNN accelerator. Theresources available may include a number and type of memory blocks, DSPblocks, and other components and processing units on a target. Accordingto an embodiment of the present invention where a plurality of CNNalgorithms are desired to be executed on the CNN accelerator, a range orplurality of characteristics and parameters may be identified for theCNN accelerator.

The EDA tool 1500 includes a buffer allocation unit 1530. According toan embodiment of the present invention, the buffer allocation unit 1530assigns buffers to the CNN accelerator at an appropriate size to supporta size of images to be processed by the CNN accelerator.

The EDA tool 1500 includes a computation unit generation unit 1540. Thecomputation unit generation unit 1540 generates computation units suchas processing element arrays to support the CNN algorithms to beperformed by the CNN accelerator. According to an embodiment of thepresent invention, the processing element arrays include kernels thatperform convolution and noise filtering. The processing element arraysmay be generated to optimize performance utilizing resources availableon a target used to implement the CNN accelerator.

The EDA tool 1500 includes a sequencer generation unit 1550. Thesequencer generation unit 1550 generates and programs a sequencer unitthat coordinates transmission of data to appropriate processing elementarrays on the CNN accelerator, kernels in the processing element arrays,and components in the kernels at appropriate times in order to timemultiplex computations on the processing element arrays. According to anembodiment of the present invention, the sequencer unit may beprogrammed to perform the procedures illustrated with reference to FIGS.11-13.

According to an embodiment of the present invention, information fromthe buffer allocation unit 1530, computation unit generation unit 1540,and sequencer generation unit 1550 is used to generate a description ofthe design of the CNN accelerator. The description of the design may bein HDL format or other format.

The EDA tool 1500 includes an HDL compilation unit 1560. The HDLcompilation unit 1560 compiles a description of the design for the CNNaccelerator for the target. According to an embodiment of the presentinvention, compilation involves performing synthesis, placement,routing, and timing analysis procedures on the HDL description of thedesign. The compiled design for the CNN accelerator may support a rangeof CNN variants. It should be appreciated that the EDA tool 1500 mayperform the procedures described with reference to FIGS. 1-4.

FIG. 16 illustrates a CNN accelerator configuration tool 1600 accordingto an embodiment of the present invention. The CNN acceleratorconfiguration tool 1600 may be used to implement the configuration tool1422 illustrated in FIG. 14. The CNN accelerator configuration tool 1600may be used to configure a system such as a CNN accelerator on one ormore target devices such as an FPGA, ASIC, structured ASIC, or othercircuitry. FIG. 16 illustrates modules implementing an embodiment of theCNN accelerator configuration tool 1600. According to one embodiment,the modules represent software modules and configuring a CNN acceleratormay be performed by a computer system such as the one illustrated inFIG. 14 executing sequences of instructions represented by the modulesshown in FIG. 16. Execution of the sequences of instructions causes thecomputer system to support configuration of a CNN accelerator as will bedescribed hereafter. In alternate embodiments, hard-wire circuitry maybe used in place of or in combination with software instructions toimplement embodiments of present invention. Thus, embodiments of presentinvention are not limited to any specific combination of hardwarecircuitry and software.

The CNN accelerator configuration tool 1600 includes a configurationtool manager 1610. The configuration tool manager 1610 is connected toand transmits data between the other components of the configurationtool manager 1600. The configuration tool manager 1610 provides aninterface that allows a user to input data into the configuration tool1600.

The CNN accelerator configuration tool 1600 includes a target programmerunit 1620. The target programmer unit 1620 programs the target toimplement a CNN accelerator. According to an embodiment of the presentinvention, programming the target involves programming one or moretarget devices with a configuration file that physically transforms theone or more target devices into the design of the CNN accelerator.

The CNN accelerator configuration tool 1600 includes a CNN algorithmidentification unit 1630. The CNN algorithm identification unit 1630identifies a CNN algorithm to be executed by the CNN accelerator.According to an embodiment of the present invention, the CNN algorithmto be executed may be identified from user input or from another source.

The CNN accelerator configuration tool 1600 includes a CNN acceleratorvariation identification unit 1640. The CNN accelerator variationidentification unit 1640 identifies an appropriate variation of the CNNaccelerator that supports the CNN algorithm to be executed. According toan embodiment of the present invention, the appropriate variation of theCNN accelerator may be identified from user input or from anothersource.

The CNN accelerator configuration tool 1600 includes a configurablestatus register unit 1650. The configurable status register unit 1650sets one or more configurable status registers to support the variationof the CNN accelerator identified. According to an embodiment of thepresent invention, setting a configurable status register may add orsubtract a convolution layer on the CNN accelerator, add or subtract oneor more pooling layers, or change a size of a filter.

It should be appreciated that the CNN algorithm identification unit 1630may make a determination as to whether a new CNN algorithm is to beexecuted by the CNN accelerator. If a determination is made that a newCNN algorithm is to be executed by the CNN accelerator, an appropriateCNN accelerator variation may be identified by configuration acceleratorvariation identification unit 1640, and configurable status registersmay be set by the configurable status register unit 1650 to support theCNN accelerator variation. It should be appreciated that the CNNaccelerator configuration tool 1600 may perform the procedures describedwith reference to FIG. 5.

It should be appreciated that embodiments of the present invention maybe provided as a computer program product, or software, that may includea computer-readable or machine-readable medium having instructions. Theinstructions on the computer-readable or machine-readable medium may beused to program a computer system or other electronic device. Themachine-readable medium may include, but is not limited to, floppydiskettes, optical disks, CD-ROMs, and magneto-optical disks or othertype of media/machine-readable medium suitable for storing electronicinstructions. The techniques described herein are not limited to anyparticular software configuration. They may find applicability in anycomputing or processing environment. The terms “computer-readablemedium” or “machine-readable medium” used herein shall include anymedium that is capable of storing or encoding a sequence of instructionsfor execution by the computer and that cause the computer to perform anyone of the methods described herein. Furthermore, it is common in theart to speak of software, in one form or another (e.g., program,procedure, process, application, module, unit, logic, and so on) astaking an action or causing a result. Such expressions are merely ashorthand way of stating that the execution of the software by aprocessing system causes the processor to perform an action to produce aresult.

FIG. 17 illustrates a device 1700 that may be used to implement a targetdevice according to an embodiment of the present invention. The device1700 is a field programmable gate array (FPGA) that includes a pluralityof logic-array blocks (LABs). Each LAB may be formed from a plurality oflogic blocks, carry chains, LAB control signals, look up table (LUT)chain, and register chain connection lines, and other components andinterconnects. A logic block is a small unit of logic providingefficient implementation of user logic functions. A logic block includesone or more combinational cells, where each combinational cell has asingle output, and registers. According to one embodiment of the presentinvention, the logic block may operate similarly to a logic element(LE), such as those found in the Stratix or Cyclone devices manufacturedby Altera® Corporation, or a combinational logic block (CLB) such asthose found in Virtex devices manufactured by Xilinx Inc. In thisembodiment, the logic block may include a four input LUT with aconfigurable register. According to an embodiment of the presentinvention, the logic block may include one or more adaptive logicmodules (ALMs), such as those found in Stratix devices manufactured byAltera Corporation. ALMs may be configured to implement logic functions,arithmetic functions, and register functions. LABs are grouped into rowsand columns across the device 1700. Columns of LABs are shown as1711-1716. It should be appreciated that the logic block may includeadditional or alternate components.

The device 1700 includes memory blocks. The memory blocks may be, forexample, dual port random access memory (RAM) blocks that providededicated true dual-port, simple dual-port, or single port memory up tovarious bits wide at up to various frequencies. The memory blocks may begrouped into columns across the device in between selected LABs orlocated individually or in pairs within the device 1700. Columns ofmemory blocks are shown as 1721-1724. According to an embodiment of thepresent invention, CSRs may be implemented by one or more of the memoryblocks in columns 1721-1724. The CSRs may be used to provide status tokernels in order to configure a CNN accelerator according to desiredfeatures of a CNN. This allows a CNN accelerator implemented by thetarget device 1700 to be configured during runtime.

The device 1700 includes digital signal processing (DSP) blocks. The DSPblocks may be used to implement multipliers of various configurationswith add or subtract features. The DSP blocks include shift registers,multipliers, adders, and accumulators. The DSP blocks may be groupedinto columns across the device 1700 and are shown as 1731.

The device 1700 includes a plurality of input/output elements (IOEs)1740. Each IOE feeds an IO pin (not shown) on the device 1700. The IOEs1740 are located at the end of LAB rows and columns around the peripheryof the device 1700. Each IOE may include a bidirectional IO buffer and aplurality of registers for registering input, output, and output-enablesignals.

The device 1700 may include routing resources such as LAB localinterconnect lines, row interconnect lines (“H-type wires”), and columninterconnect lines (“V-type wires”) (not shown) to route signals betweencomponents on the target device.

In the foregoing specification, embodiments of the invention have beendescribed with reference to specific exemplary embodiments thereof. Itwill, however, be evident that various modifications and changes may bemade thereto without departing from the broader spirit and scope of theembodiments of the invention. The specification and drawings are,accordingly, to be regarded in an illustrative rather than restrictivesense.

What is claimed is:
 1. A method for implementing a convolutional neuralnetwork (CNN) accelerator on a target, comprising: utilizing one or moreprocessing elements to implement a standard convolution layer; modifyinga configuration of the CNN accelerator to change a data flow betweencomponents on the CNN accelerator; and utilizing the one or moreprocessing elements to implement a fully connected layer in response tothe change in the data flow.
 2. The method of claim 1, wherein modifyingthe configuration of the CNN accelerator comprises: storing inputfeature maps in caches in the one or more processing elements; storingcoefficient data in a buffer on the target; and streaming thecoefficient data into the one or more processing elements.
 3. The methodof claim 2 further comprising: storing an output feature map in at leastone of the caches if another fully-connected layer is to be implemented;and storing the output feature map in a memory external to the target ifno additional fully-connected layer is to be implemented.
 4. The methodof claim 1 further comprising setting an initial configuration of theCNN accelerator to implement the standard convolution layer comprising:storing an input feature map in a buffer on the target; streaming theinput feature map into the one or more processing elements; and storingcoefficient data in a cache in the one or more processing elements. 5.The method of claim 4 further comprising: storing an output feature mapin the buffer on the target if another standard convolution layer is tobe implemented; and storing the output feature map in a memory externalto the target if no additional standard convolution layer is to beimplemented.
 6. The method of claim 1, wherein the modifying isperformed by a sequencer unit residing on the CNN accelerator duringruntime of the CNN accelerator.
 7. The method of claim 1, wherein theone or more processing elements implements either the standardconvolution layer or the fully connected layer at an instance of time.8. The method of claim 1, wherein each of the one or more processingelements comprises: a cache; a computation unit that performs dotproduct operations; and an accumulator unit.
 9. The method of claim 1,wherein the standard convolution layer generates an output feature mapthat includes outputs which are the sum of multiplications of differentsets of data from an input feature map and a set of fixed coefficientdata.
 10. The method of claim 1, wherein the fully-connected layergenerates an output feature map that includes outputs which are the sumof multiplications of a fixed set of data from an input feature map anddifferent sets of coefficient data.
 11. A convolutional neural network(CNN) accelerator implemented on a target, comprising: a sequencer unitthat coordinates a first data flow between components on the targetduring a first configuration and that coordinates a second data flowbetween components on the target during a second configuration; and aplurality of processing elements that implement a standard convolutionallayer during the first configuration, and that implement a fullyconnected layer during the second configuration.
 12. The CNN acceleratorof claim 11, wherein each of the plurality of processing elementscomprises: a cache; a computation unit that performs dot productoperations; and an accumulator unit.
 13. The CNN accelerator of claim11, wherein the plurality of processing elements implement either thestandard convolution layer or the fully connected layer at an instanceof time.
 14. The CNN accelerator of claim 11, wherein the first dataflow comprises: storing an input feature map in a buffer on the target;streaming the input feature map into the plurality of processingelements; and storing coefficient data in a cache in the pluralityprocessing elements.
 15. The CNN accelerator of claim 14 furthercomprising: storing an output feature map in the buffer on the target ifanother standard convolution layer is to be implemented; and storing theoutput feature map in a memory external to the target if no additionalstandard convolution layer is to be implemented.
 16. The CNN acceleratorof claim 11, wherein the second data flow comprises: storing inputfeature maps of different images in caches in the plurality ofprocessing elements; storing coefficient data in a buffer on the target;and streaming the coefficient data into the plurality of processingelements.
 17. The CNN accelerator of claim 16 further comprising:storing an output feature map in at least one of the caches if anotherfully-connected layer is to be implemented; and storing the outputfeature map in a memory external to the target if no additionalfully-connected layer is to be implemented.
 18. A non-transitorycomputer readable medium including a sequence of instructions storedthereon for causing a computer to execute a method for implementing aconvolutional neural network (CNN) accelerator on a target, comprising:utilizing one or more processing elements to implement a standardconvolution layer; modifying a configuration of the CNN accelerator tochange a data flow between components on the CNN accelerator; andutilizing the one or more processing elements to implement a fullyconnected layer in response to the change in the data flow.
 19. Thenon-transitory computer readable medium of claim 18, wherein modifyingthe configuration of the CNN accelerator comprises: storing an inputfeature map in a cache in the one or more processing elements; storingcoefficient data in a buffer on the target; and streaming thecoefficient data into the one or more processing elements.
 20. Thenon-transitory computer readable medium of claim 11, wherein the one ormore processing elements implements either the standard convolutionlayer or the fully connected layer at an instance of time.